#include "allele_frequencies.h"

AlleleFrequencies::AlleleFrequencies() {
}

void AlleleFrequencies::addIndividual( Individual *ind ) {
    QStringList locusNames = ind->locusNames();
    foreach(QString locus, locusNames ) {
        if( !_freqs.keys().contains( locus) )
            _freqs[locus] = new LocusFrequency();
        _freqs[locus]->addLocus( ind->getLocus(locus ) );
    }
}

void AlleleFrequencies::addPopulation( QList<Individual*> inds ) {
    foreach(Individual *ind, inds )
        addIndividual(ind);
}

LocusFrequency* AlleleFrequencies::getLocusFrequency( QString key ) {
    if( _freqs.keys().contains( key ) )
        return _freqs[key];
    else
        return new LocusFrequency();
}

QStringList AlleleFrequencies::locusNames() {
    QStringList ret = _freqs.keys();
    ret.sort();
    return ret;
}
